﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ArtCube : System.Web.UI.MasterPage
{
    private LocalFunctions _func = null;
    protected string sRightFooterText;
    protected string sLeftFooterText;
    protected string sIconList;
    protected string sCopyright;

    public LocalFunctions FUNC
    {
        get
        {
            if (_func == null)
                _func = new LocalFunctions();
            return _func;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (FUNC.LangID == 1)
        {
            AddDynamicCss("site.css");
            Page.Culture = "he-IL";
        }
        else
        {
            AddDynamicCss("site.css");
            Page.Culture = "he-IL";
        }

        SelectMenuItem();

        // Get Footer
        Dal.arParams.Clear();
        Dal.arParams.Add(3);//Footer type
        Dal.arParams.Add(FUNC.LangID); // Curent language
        DataTable DT = Dal.ExecuteDBsp("GetPageByTypeID", Dal.arParams);
        if (DT != null)
            if (DT.Rows.Count > 0)
            {
                DataRow dRow = DT.Rows[0];
                sRightFooterText = dRow["Title"].ToString();
                sLeftFooterText = dRow["Content"].ToString();
            }
        //Get footer icons
        DataTable DTIcons = Dal.ExecuteDBsp("Admin_GetFooterIcons");
        if (DTIcons != null)
            if (DTIcons.Rows.Count > 0)
            {
                foreach (DataRow row in DTIcons.Rows)
                {
                    sIconList+=string.Format("<a href='{0}'>",row["NavigateURL"].ToString());
                    sIconList += string.Format("<img src='content/galery/{0}'  onmouseout='this.src=\"content/galery/{0}\"' onmouseover='this.src=\"content/galery/{1}\"'/></a>", row["Icon"].ToString(), row["IconHover"].ToString());
                }
            }

        //Set Copyright 
        sCopyright = FUNC.GetPhrase(14);
        sCopyright = sCopyright.Replace("YYYY", DateTime.Now.Year.ToString());
    }
    

    private void SelectMenuItem()
    {
        switch (Request.Url.Segments[Request.Url.Segments.Length - 1].ToLower())
        {
            case "default.aspx":
                lnkHome.CssClass = "MenuHomeSelected";
                break;

            case "about.aspx":
                lnkAbout.CssClass = "MenuAboutSelected";
                break;

            case "work.aspx":
            case "portfolio.aspx":
                lnkPortfolio.CssClass = "MenuPortfolioSelected";
                break;
           
            case "pricelist.aspx":
                lnkSale.CssClass = "MenuSaleSelected";
                break;

            case "contact.aspx":
                lnkContact.CssClass = "MenuContactSelected";
                break;
        }
    }

    private void AddDynamicCss(string sFileName)
    {
        mainStyle.Href = "Content/" + sFileName;
        mainStyle.Attributes.Add("rel", "stylesheet");
        mainStyle.Attributes.Add("type", "text/css");
    }
}
